package com.org.csu.dao;

import com.org.csu.dto.KeywordDTO;
import com.org.csu.entity.Keyword;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author YigongLily
 * @version V1.0
 * Copyright (c) 2024, t8669@qq.com All Rights Reserved.
 * @ProjectName:e-commerce-back
 * @Title: KeywordRepository
 * @Package com.org.csu.dao
 * @Description: keywordR
 * @date 2024/12/15 10:50
 */
@Repository
public interface KeywordRepository extends JpaRepository<Keyword, Integer> {
    //根据关键词和日期查询关键词信息
    @Query("SELECT k FROM Keyword k WHERE k.word =:word AND k.date = :date")
    List<Keyword> findByWordAndDate(@Param("word")String word, @Param("date")String date);
    //根据关键词和日期查询长尾词
    @Query("SELECT k FROM Keyword k WHERE k.word LIKE %:word% AND k.date = :date")
    List<Keyword> findAllByWordAndDate(String word,String date);
    //根据关键词和日期范围查询关键词热度趋势
    @Query("SELECT k FROM Keyword k WHERE k.word = :keyword AND k.date IN :dates")
    List<Keyword> findHotTrendWithDate(@Param("keyword") String keyword, @Param("dates") List<String> dates);
}